#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Base64是一种任意二进制到文本字符串的编码方法，常用于在URL、Cookie、网页中传输少量二进制数据。
"""
import base64

encode = base64.b64encode(b'binary\x00string')
print(encode)
decode = base64.b64decode(b'YmluYXJ5AHN0cmluZw==')
print(decode)


encode2 = base64.b64encode(b'i\xb7\x1d\xfb\xef\xff')
print(encode2)
urlencode = base64.urlsafe_b64encode(b'i\xb7\x1d\xfb\xef\xff')
print(urlencode)
urldecode = base64.urlsafe_b64decode('abcd--__')
print(urldecode)